//
//  DetailsBottomBar.m
//  BestPurchase
//
//  Created by ZSMAC on 2018/10/15.
//  Copyright © 2018年 张帅. All rights reserved.
//

#import "DetailsBottomBar.h"

@implementation DetailsBottomBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=MyRGB(247, 247, 247);
        [self uiSet];
    }
    return self;
}
- (void)uiSet {
    CGFloat width =(SCREEN_WIDTH/5)*3-20;
    UIView * basisView = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-width-15, 5, width, self.height-10)];
    basisView.layer.cornerRadius=basisView.height/2;
    basisView.layer.masksToBounds=YES;
    basisView.backgroundColor=themeColor;
    [self addSubview:basisView];
    
    for (int i = 0; i<2; i++) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame=CGRectMake(i*basisView.width/2, 0, basisView.width/2, basisView.height);
        if (i==0) {
            [btn setTitle:@"加入购物车" forState:UIControlStateNormal];
        } else {
            [btn setTitle:@"立即购买" forState:UIControlStateNormal];
        }
        btn.titleLabel.font=Font(14);
        [btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [basisView addSubview:btn];
    }
    NSArray * titles = @[@"店铺",@"客服",@"收藏",];
    NSArray * imageNames = @[@"店铺.png",@"联系客服.png",@"收藏.png",];
    CGFloat btnWidth  = (SCREEN_WIDTH-basisView.width-30)/3;
    for (int i=0; i<3; i++) {
        MCustomButton * btn = [MCustomButton buttonWithType:UIButtonTypeCustom];
        btn.frame=CGRectMake(i*btnWidth+10, 5, btnWidth, self.height-10);
        [btn setTitle:titles[i] forState:UIControlStateNormal];
        btn.imageRect=CGRectMake((btn.width/2)- 10, 0, 20, 20);
        [btn setImage:[UIImage imageNamed:imageNames[i]] forState:UIControlStateNormal];
        btn.titleRect=CGRectMake(0, btn.height-13, btn.width, 13);
        btn.titleLabel.font=Font(12);
        btn.titleLabel.textAlignment=NSTextAlignmentCenter;
        [btn setTitleColor:MyRGB(153, 153, 153) forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn];
    }
    
}

- (void)btnClicked:(UIButton *)btn {
    
}
@end
